# Importar las librerĆas necesarias segĆŗn el anĆ”lisis que se vaya a realizar
# LibrerĆa para comando de sistema
import os
# LibrerĆa para manejo de datos
import pandas as pd
# LibrerĆas para graficar
# El uso de plotly permite analizar los grƔficos pasando el mouse sobre ellas
# tambiƩn se puede redimensionar el grƔfico a conveniencia
import plotly.express as px
# cargar los datos en csv
data= pd.read_csv('listings_m.csv', sep=';',encoding='UTF-8', low_memory=False)
# Visualizar los datos
data.head()
| id | listing_url | scrape_id | last_scraped | name | description | neighborhood_overview | picture_url | host_id | host_url | ... | review_scores_communication | review_scores_location | review_scores_value | license | instant_bookable | calculated_host_listings_count | calculated_host_listings_count_entire_homes | calculated_host_listings_count_private_rooms | calculated_host_listings_count_shared_rooms | reviews_per_month | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2818 | https://www.airbnb.com/rooms/2818 | 2,02104E+13 | 12/04/2021 | Quiet Garden View Room & Super Fast WiFi | Quiet Garden View Room & Super Fast WiFi<br />... | Indische Buurt ("Indies Neighborhood") is a ne... | https://a0.muscache.com/pictures/10272854/8dcc... | 3159 | https://www.airbnb.com/users/show/3159 | ... | 10.0 | 9.0 | 10.0 | NaN | t | 1 | 0 | 1 | 0 | 1.90 |
| 1 | 20168 | https://www.airbnb.com/rooms/20168 | 2,02104E+13 | 12/04/2021 | Studio with private bathroom in the centre 1 | 17th century Dutch townhouse in the heart of t... | Located just in between famous central canals.... | https://a0.muscache.com/pictures/69979628/fd6a... | 59484 | https://www.airbnb.com/users/show/59484 | ... | 10.0 | 10.0 | 9.0 | 0363 CBB3 2C10 0C2A 1E29 | t | 2 | 0 | 2 | 0 | 2.50 |
| 2 | 25428 | https://www.airbnb.com/rooms/25428 | 2,02104E+13 | 11/04/2021 | Lovely, 1 bed apt in Ctr (w.lift) -3/20-6/20(f... | Lovely apt in Centre ( lift & fireplace) near ... | NaN | https://a0.muscache.com/pictures/138431/7079a9... | 56142 | https://www.airbnb.com/users/show/56142 | ... | 10.0 | 10.0 | 10.0 | NaN | f | 2 | 2 | 0 | 0 | 0.13 |
| 3 | 27886 | https://www.airbnb.com/rooms/27886 | 2,02104E+13 | 11/04/2021 | Romantic, stylish B&B houseboat in canal district | Stylish and romantic houseboat on fantastic hi... | Central, quiet, safe, clean and beautiful. | https://a0.muscache.com/pictures/02c2da9d-660e... | 97647 | https://www.airbnb.com/users/show/97647 | ... | 10.0 | 10.0 | 10.0 | 0363 974D 4986 7411 88D8 | t | 1 | 0 | 1 | 0 | 1.94 |
| 4 | 28871 | https://www.airbnb.com/rooms/28871 | 2,02104E+13 | 13/04/2021 | Comfortable double room | <b>The space</b><br />In a monumental house ri... | Flower market , Leidseplein , Rembrantsplein | https://a0.muscache.com/pictures/160889/362340... | 124245 | https://www.airbnb.com/users/show/124245 | ... | 10.0 | 10.0 | 10.0 | 0363 607B EA74 0BD8 2F6F | f | 2 | 0 | 2 | 0 | 2.59 |
5 rows Ć 74 columns
ĀæCuĆ”l es el tipo de inmueble que mĆ”s ha publicados Airbnb en la ciudad de Ćmsterdam?
dataFil = data['room_type'].value_counts().reset_index()
# cambiamos el nombre de las columnas
dataFil.columns=['Tipo_inmueble','Conteo']
fig = px.bar(dataFil, x='Tipo_inmueble', y='Conteo', color= 'Tipo_inmueble')
fig.show()
¿Qué tipo de habitaciones posee los precios mÔs económicos de la ciudad?
datas = data.groupby(['price', 'room_type']).count()[['id']].reset_index()
datas=datas[datas['price']>0]
datas1=datas[datas['price']>=130]
datas2=datas[datas['price']<130]
datas['precios_cond'] = datas['price'].apply(lambda x: 'Mayor' if x >= 130 else 'Menor')
fig = px.histogram(datas, x='room_type', y='id',color='precios_cond',barmode='group')
fig.show()
¿CuÔl es el tipo de habitación que posee la mayor dispersión en sus precios de alquiler?
datas = data.groupby(['price', 'room_type']).count()[['id']].reset_index()
datas=datas[datas['price']>0]
fig = px.box(datas, x="price", y="room_type")
fig.show()
Pregunta 4 ¿Las casas y apartamentos con las mejores calificaciones de revisión describen altos precios de alquiler?
datas = data.groupby(['price', 'room_type', 'review_scores_rating']).count()[['id']].reset_index()
datas=datas[datas['price']>0]
datas['score'] = datas['review_scores_rating'].apply(lambda x: 'Alto' if x >= 88 else 'Bajo')
fig = px.box(datas, x="price", y="room_type", color='score')
fig.show()